package com.molin.threadTest.FoodityAndCooker;

public class Cooker extends Thread {
    @Override
    public void run() {
        while (true){
            synchronized (Desk.lock){
                if(Desk.count==0){break;}else {
                    //桌子上有汉堡，等待
                    if(!Desk.flag){
                        //桌子上没有汉堡，需要生产
                        System.out.println("厨师在生产汉堡包");
                        Desk.flag=true;//桌子上有汉堡了，可以叫吃货来吃
                        Desk.lock.notifyAll();

                    }else {
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
